package com.orkasgb.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.orkasgb.common.CommonResult;
import com.orkasgb.entity.OrkasgbProcessEntity;
import com.orkasgb.service.IOrkasgbProcessService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.Serializable;
import java.util.List;

/**
 * 流程信息表(TOrkasgbProcess)表控制层
 *
 * @version 1.0.0
 * @since 2024-09-08 21:17:22
 */
@RestController
@RequestMapping("orkasgbProcess")
public class OrkasgbProcessController {
	
	/**
	 * 服务对象
	 */
	@Resource
	private IOrkasgbProcessService orkasgbProcessService;
	
	/**
	 * 通过主键查询单条数据
	 *
	 * @param id 主键
	 * @return 单条数据
	 */
	@GetMapping("getOrkasgbProcess/{id}")
	public CommonResult<OrkasgbProcessEntity> getOrkasgbProcess (@PathVariable("id") Serializable id) {
		return CommonResult.ofSuccess(orkasgbProcessService.getOrkasgbProcess(id));
	}
	
	/**
	 * 通过条件查询多条数据
	 *
	 * @param orkasgbProcess 实体查询参数
	 * @return 单条数据
	 */
	@GetMapping("getOrkasgbProcessList")
	public CommonResult<List<OrkasgbProcessEntity>> getOrkasgbProcessList (@ModelAttribute OrkasgbProcessEntity orkasgbProcess) {
		return CommonResult.ofSuccess(orkasgbProcessService.getOrkasgbProcessList(orkasgbProcess));
	}
	
	/**
	 * 通过条件查询多条数据(分页查询)
	 *
	 * @param orkasgbProcess 查询参数
	 * @return 单条数据
	 */
	@GetMapping("getOrkasgbProcessPageDataList")
	public CommonResult<IPage<OrkasgbProcessEntity>> getOrkasgbProcessPageDataList (@ModelAttribute OrkasgbProcessEntity orkasgbProcess) {
		return CommonResult.ofSuccess(new Page<OrkasgbProcessEntity>().setRecords(orkasgbProcessService.getOrkasgbProcessPageDataList(orkasgbProcess)));
	}
	
	/**
	 * 新增数据
	 *
	 * @param orkasgbProcess 实体对象
	 * @return 新增结果
	 */
	@PostMapping("addOrkasgbProcess")
	public CommonResult<Integer> addOrkasgbProcess (@RequestBody OrkasgbProcessEntity orkasgbProcess) {
		orkasgbProcessService.addOrkasgbProcess(orkasgbProcess);
		return CommonResult.ofSuccess(orkasgbProcess.getId().intValue());
	}
	
	/**
	 * 修改数据
	 *
	 * @param orkasgbProcess 实体对象
	 * @return 修改结果
	 */
	@PutMapping("updateOrkasgbProcess")
	public CommonResult<Integer> updateOrkasgbProcess (@RequestBody OrkasgbProcessEntity orkasgbProcess) {
		return CommonResult.ofSuccess(orkasgbProcessService.updateOrkasgbProcess(orkasgbProcess));
	}
	
	/**
	 * 修改或者新增数据
	 *
	 * @param orkasgbProcessList 实体对象
	 * @return 操作结果
	 */
	@PostMapping("addOrUpdateOrkasgbProcess")
	public CommonResult<Integer> addOrUpdateOrkasgbProcess (@RequestBody List<OrkasgbProcessEntity> orkasgbProcessList) {
		return CommonResult.ofSuccess(orkasgbProcessService.addOrUpdateOrkasgbProcess(orkasgbProcessList));
	}
	
	/**
	 * 删除数据
	 *
	 * @param idList 主键结合
	 * @return 删除结果
	 */
	@DeleteMapping("deleteOrkasgbProcessByIds")
	public CommonResult<Integer> deleteOrkasgbProcessByIds (@RequestParam("idList") List<Long> idList) {
		return CommonResult.ofSuccess(orkasgbProcessService.deleteOrkasgbProcessByIds(idList));
	}
	
}

